473,461 Members | 2,165 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

JavaScript Button OnClick Disable and Change Value

kestrel
1,071 Expert 1GB
i need a button, that onclick changes value to "Sending" and disables so the cant click it again
Heres what i have
Expand|Select|Wrap|Line Numbers
  1. <input type="button" value="Submit" onclick="this.disabled=1; this.form.submit();">
but i cant seem to make
Expand|Select|Wrap|Line Numbers
  1. this.value=Sending;
to work with the other two scripts in the button.

Is it possible?

--Thanks
Aug 6 '06 #1
4 34695
kestrel
1,071 Expert 1GB
NVM i figured it out
sorry
Aug 6 '06 #2
Frinavale
9,735 Expert Mod 8TB
How did you get it to work?
I'm having a similar problem. The button disables but it will not send the postback request.
Dec 22 '06 #3
I wouldn't do this in-line, but here you go as a function. You'll need to name the form also, by the way.

Put this in your HTML header:
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function submitted(){
    button1 = getElementsByName("submit")[0];
  3. form1 = getElementsByName("--place form name here--")[0];
  4. if (button1.value == "Submit"){
    button1.value="Sending...";
  5. form1.submit();}else {return false;}}
  6. </script>
  7.  
And here's the button code:
Expand|Select|Wrap|Line Numbers
  1. <input name="submit" type="button" value="Submit" 
  2. onclick="return submitted();">
Mar 8 '07 #4
Hello!

Well i modified the function and become that way:

function disableSubmit(botao,formulario){

document.getElementById(botao).value = "Processando...";

document.getElementById(botao).disabled = true;
document.formulario.submit();
}

and in the form, put in the form tag the following onSubmit satatement as follows:

<form method="post" name="formViagem" onSubmit=disableSubmit("gravarApenas","formViagem" );>

This way, the button be disabled and the form is submitted correctly (the user cannot press more than one time if the form is submitting).

[]s
Márcio
Apr 18 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.